package com.ruoyi.generator.enums;

import org.apache.commons.collections.CollectionUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum GenModelEnum {
    TABLE("0","基于表"),
    BY_HAND("1","手动创建");

    GenModelEnum(String genModel, String desc) {
        this.genModel = genModel;
        this.desc = desc;
    }

    private String genModel;
    private String desc;

    public String getGenModel() {
        return genModel;
    }

    public void setGenModel(String genModel) {
        this.genModel = genModel;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static String getDescByGenModel(String genModel){
        GenModelEnum[] values = GenModelEnum.values();
        List<GenModelEnum> genModelEnums = Arrays.asList(values);
        List<GenModelEnum> collect = genModelEnums.stream()
                .filter(p -> p.getGenModel().equals(genModel))
                .collect(Collectors.toList());
        if(CollectionUtils.isNotEmpty(collect) && collect.size()>0){
            GenModelEnum genModelEnum = collect.get(0);
            return genModelEnum.getDesc();
        }
        return "";
    }
}
